package Operation;
import book.Book;
import book.BookList;
import java.util.Scanner;
public class Add implements Operation{
    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入书名");
        String name = scanner.nextLine();
        System.out.println("请输入作者");
        String author = scanner.nextLine();
        System.out.println("请输入价格");
        int price = scanner.nextInt();
        Book newbook = new Book(name,author,price);
        int size = bookList.getUsedSize();
        for (int i = 0; i <size ; i++) {
            if(bookList.getBooks(i).equals(name)){
                System.out.println("已有这本书");
                return;
            }
        }
        bookList.setBooks(size,newbook);
        bookList.setUsedSize(size+1);
    }
}
